from django import template
from gestion.monedas.models import *
from gestion import settings
register = template.Library()

def moneda(simbolo):
    return Moneda.objects.get(simbolo=simbolo)

@register.simple_tag
def moneda_id(simbolo):
    try:
        return moneda(simbolo).id
    except:
	return "?"

@register.simple_tag
def cotizacion(simbolo):
    try:
        return moneda(simbolo).cotizacion_actual()
    except:
	return "?"


@register.simple_tag
def today():
    import datetime
    return datetime.date.today().strftime(settings.DATE_OUTPUT_FORMAT)




